package com.kotlin.heimaplayer.util

import com.kotlin.heimaplayer.R
import com.kotlin.heimaplayer.base.BaseFragment
import com.kotlin.heimaplayer.ui.fragment.HomeFragment
import com.kotlin.heimaplayer.ui.fragment.MvFragment
import com.kotlin.heimaplayer.ui.fragment.VBangFragment
import com.kotlin.heimaplayer.ui.fragment.YueDanFragment

/**
 * 管理Fragment
 */

class FragmentUtil private constructor(){

    val homeFragment by lazy { HomeFragment() }
    val mvFragment by lazy { MvFragment() }
    val vBangFragment by lazy { VBangFragment() }
    val yueDanFragment by lazy { YueDanFragment() }

    companion object{
        val fragmentUtil by lazy { FragmentUtil() }
    }

    /**
     * 根据tabid获取对应的fagment
     */
    fun getFragment(tabId:Int):BaseFragment?{
        when(tabId){
            R.id.tab_home->return homeFragment
            R.id.tab_mv->return mvFragment
            R.id.tab_vbang->return vBangFragment
            R.id.tab_yuedan->return yueDanFragment
        }
        return null
    }
}